package cn.itsource.user.controller;

import cn.itsource.user.domain.TUser;
import cn.itsource.user.service.IUserService;
import cn.itsource.utils.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    private IUserService userService;

    @GetMapping("/checkphone/{phone}")
    public AjaxResult checkPhone(@PathVariable("phone") String telephone){
        //根据这个手机号数据库中，查询这个手机号是否存在
        return userService.checkPhone(telephone);
    }

    @GetMapping("/sendmobilecode/{phone}")
    public AjaxResult sendMobileCode(@PathVariable("phone") String phone){
        return userService.sendMobileCode(phone);
    }

    @PostMapping
    public AjaxResult register(@RequestBody TUser user){

        return userService.register(user);
    }

}
